package com.lwf.thymeleafdemo1.mysqlTest.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lwf.thymeleafdemo1.global.WrapperResponse;
import com.lwf.thymeleafdemo1.mysqlTest.entity.PsnInfoBDTO;
import com.lwf.thymeleafdemo1.mysqlTest.entity.PsnInfoBVO;
import com.lwf.thymeleafdemo1.mysqlTest.service.PsnInfoBService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Author makejava
 * @Desc (PsnInfoB)表控制层
 * @Date 2023-07-22 16:07:58
 */
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class PsnInfoBController {
    @Resource(name = "psnInfoBService")
    private PsnInfoBService psnInfoBService;


    @PostMapping("/queryByPage")
    public WrapperResponse<IPage> queryByPage(@RequestBody PsnInfoBDTO param) {
        return psnInfoBService.queryByPage(param);
    }



    @PostMapping("/queryById")
    public WrapperResponse<PsnInfoBVO> queryById(@RequestBody PsnInfoBDTO param) {
        return psnInfoBService.queryById(param.getPsnNo());
    }



    @PostMapping("/insert")
    public WrapperResponse insert(@RequestBody PsnInfoBDTO param) {
        return psnInfoBService.insert(param);
    }



    @PostMapping("/update")
    public WrapperResponse update(@RequestBody PsnInfoBDTO param) {
        if (Objects.isNull(param.getPsnNo())) {
            return WrapperResponse.failed("ID不能为空");
        }
        return psnInfoBService.update(param);
    }



    @PostMapping("/deleteById")
    public WrapperResponse deleteById(@RequestBody PsnInfoBDTO param) {
        return psnInfoBService.deleteById(param.getPsnNo());
    }

}
